<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class MapEditor extends MY_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper("file");
    }

    public function index() {
        $this->_data["useMap"] = true;
        $this->_data["menuHL"] = "Home";

        $this->_renderPage("mapeditor");
    }

    public function loadFile($fileName) {
        $result = read_file("./application/res/vectors/" . $fileName);
        echo $result;
        exit;
    }

    public function getFiles() {
        echo json_encode(get_filenames("./application/res/vectors"));
    }

    public function save() {
        $fileName = $this->input->post("fileName");
        $data = $this->input->post("wkt");
        write_file("./application/res/vectors/" . $fileName, $data);
        echo $fileName;
    }

}
